package main

import (
	"ReaderInOutLog/cmd"
	"ReaderInOutLog/model"
	"ReaderInOutLog/routes"
	"ReaderInOutLog/util"
	"fmt"
	"time"
)

func main() {
	model.ConnectDB()
	fmt.Println("开始运行")
	if util.IsServer {
		fmt.Println("服务端模式")
		routes.InitRouter()
	}

	if !util.IsServer && util.IsSync {
		fmt.Println("客户端模式 开始同步数据")
		fmt.Println("util.IsSync is ", util.IsSync)
		cmd.RunSyncData()
		fmt.Println("同步数据完成")
	}

	if !util.IsServer && !util.IsSync {
		fmt.Println("客户端模式 监听表变化")
		ticker := time.NewTicker(time.Duration(util.MoniterTime) * time.Second)
		defer ticker.Stop()

		for range ticker.C {
			cmd.SyncDataTemp()
		}
	}

}
